/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.messaging.inbox;

import java.text.SimpleDateFormat;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import nl.cloudfarming.client.messaging.Message;
import nl.cloudfarming.client.messaging.MessageModule;
import org.openide.util.NbBundle;

/**
 * Display Message-properties in a panel
 * @author Gerben Feenstra
 */
public class MessageDisplayPropertyPanel extends JPanel{
    
    /**
     * Create panel
     * @param message Message to display on the panel
     */
    public MessageDisplayPropertyPanel(Message message){
        // Labels
        final JLabel titleLabel = new JLabel(NbBundle.getMessage(MessageModule.class, "messaging.messagepopup.label.title.text") + ":");
        final JLabel fromLabel = new JLabel(NbBundle.getMessage(MessageModule.class, "messaging.messagepopup.label.origin.text") + ":");
        final JLabel dateReceivedLabel = new JLabel(NbBundle.getMessage(MessageModule.class, "messaging.messagepopup.label.receivedate.text") + ":");

        // Content
        final JLabel titleContent = new JLabel();
        final JLabel fromContent = new JLabel();
        final JLabel dateReceivedContent = new JLabel();
    
        // Set text of content fields
        titleContent.setText(message.getTitle());        
        fromContent.setText(message.getOrigin());       
        dateReceivedContent.setText(new SimpleDateFormat(NbBundle.getMessage(MessageModule.class, "messaging.message.datereceived.format")).format(message.getDateReceived()));

        this.setLayout(new MigLayout("wrap 2"));
                
        this.add(titleLabel);
        this.add(titleContent, "gapleft 30");
        
        this.add(fromLabel);
        this.add(fromContent, "gapleft 30");
        
        this.add(dateReceivedLabel);
        this.add(dateReceivedContent, "gapleft 30");

        this.validate();
    }
}
